<?php

namespace App\Validate;

use App\Validate\BaseValidate;

/**
 * 验证器
 */
class ResourceBusinessNameValidate extends BaseValidate
{
    //验证规则
    protected $rule = [
        'id' => 'bail|required|integer',
        'resource_business_id' => 'bail|required|integer',
        'type_name' => 'bail|required',
        'img' => 'bail|required',
        'template' => 'bail|required|integer',
        'content' => 'bail|required',
        'is_auto_show' => 'bail|required|in:1,2',
    ];
    //自定义验证信息
    protected $message = [
        'id.required' => 'ID不能为空',
        'id.integer' => 'ID格式不正确',
        'resource_business_id.required' => '资源商ID不能为空',
        'resource_business_id.integer' => '资源商ID格式不正确',
        'type_name.required' => '名称不能为空',
        'img.required' => '图片不能为空',
        'template.required' => '模版不能为空',
        'template.integer' => '模版格式不正确',

        'content.required' => '内容不能为空',
        'is_auto_show.required' => '是否自动显示不能为空',
        'is_auto_show.in' => '是否自动显示规则不正确',
    ];

    //自定义场景
    protected $scene = [
        'add' => ['type_name', 'img'], //添加
        'detail' => ['id'], //详情
        'change' => ['id', 'type_name'], //修改
        'del' => ['id'], //删除
        'info' => ['id'], //详情

        'get_resource_type_list_by_business_name_id' => ['resource_business_id'], //根据资源商获取对应类型列表
        'get_resource_type_filter_list_by_business_name_id' => ['resource_business_id'], //根据资源商获取对应类型列表
        //  'get_resource_list_by_business_name_id' => ['resource_business_id'], //根据资源商id获取资源

        'sync_data' => ['resource_business_id'], //同步数据
        'change_template' => ['resource_business_id', 'template'], //修改模版

        'cancel_and_release' => ['ids', 'is_auto_show'], //隐藏 和 显示
        'sort_change' => ['content'], //banner 图排序
    ];
}
